layui.use(['jquery','layer','form','upload','table'],function () {

    var layer = layui.layer
        , $ = layui.jquery
        , form = layui.form
        , upload = layui.upload
        , table = layui.table;

    //返回
    backOff = function backOff() {
        var arr = localStorage.getItem("numArr");
        var numArr = arr.split(",");
        numArr.pop();
        window.parent.layui.element.tabChange('tab',numArr[numArr.length - 1]);
        localStorage.setItem("numArr",numArr);
    }
    //刷新
    refresh = function refresh(){
        window.location.reload();
    }

    //检索
    search = function search(){
        var dictSort = $('select[name=dictSort]').val();
        var trueName = $('select[name=trueName]').val();
        if(dictSort == ''){
            dictSort = '';
        }else if(dictSort == '添加'){
            dictSort = 1;
        }else if(dictSort == '删除'){
            dictSort = 2;
        }else if(dictSort == '修改'){
            dictSort = 3;
        }else if(dictSort == '查看'){
            dictSort = 4;
        }
        $.ajax({
            url: '/course/operationLogRetrieval'
            ,data: {
                'dictSort': dictSort
                ,'trueName': trueName
            }
            ,dataType: 'json'
            ,success:function(data){
                tableRender(data.data);
            }
        });
    }

    //重置检索内容
    reset = function reset(){
        $('select[name=dictSort]').val('');
        $('select[name=trueName]').val('');
    }




    $.ajax({
        url: '/course/operationLog'
        ,dataType: 'json'
        ,success:function(data){
            tableRender(data.data);
        }
    });

    function tableRender(data){
        table.render({

            elem: '#demo'
            ,data: data
            ,page: true
            ,cols: [[
                {field: 'dictCode',title: '编号',align: 'center'}
                ,{field: 'dictSort',title: '操作类型',align: 'center',templet:function (data) {
                        if(data.dictSort == '1'){
                            return '添加';
                        }else if(data.dictSort == '2'){
                            return '删除';
                        }else if(data.dictSort == '3'){
                            return '修改';
                        }else if(data.dictSort == '4'){
                            return '查看';
                        }
                    }}
                ,{field: 'updateBy',title: '操作人员',align: 'center'}
                ,{field: 'updateTime',title: '操作时间',align: 'center'}
                ,{field: 'remark',title: '操作备注',align: 'center'}
            ]]

        });
    }


})